<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>订单详情</title>
	<link rel="stylesheet" href="css/amazeui.min.css" />
	<link rel="stylesheet" href="css/app.css" />
	<link rel="stylesheet" href="css/style.css" />
	<style>
		.or_it1{
			color:#aaa;
		}
		.or_it2{
			width: 70%;
    		text-align: right;
			overflow: hidden;    
			text-overflow: ellipsis;
			white-space: nowrap;
		}
		.return_status_msg{
			color:#aaa;
		}
		.bulink:disabled {
			background: #ccc;
		}
	</style>
</head>

<body>
	<header class="am-u">
		<div class="am-u-sm-12 head_nav" style="margin:0;">
			<div class="am-u-sm-2 am-vertical-align">
				<a href="mine.html">
					<img src="img/return@2x.png" class="am-vertical-align-middle" alt="">
				</a>
			</div>
			<div class="am-u-sm-8 head_text">
				订单详情
			</div>
			<div class="am-u-sm-2">
			</div>
		</div>
	</header>
	<div style="clear:both"></div>
	<div class="am-u myDeviceLists">
		<div class="or_details">
			<p class="or_t1" id="money">加载中</p>
			<p class="or_t2" id="status_name">加载中</p>
			<p class="or_item">
				<span class="or_it1">订单号</span>
				<span class="or_it2" id="order_no">加载中</span>
			</p>
			<p class="or_item">
				<span class="or_it1">设备名称</span>
				<span class="or_it2" id="name">加载中</span>
			</p>
			<p class="or_item">
				<span class="or_it1">购买数量</span>
				<span class="or_it2" id="buy_num">加载中</span>
			</p>
			<p class="or_item">
				<span class="or_it1">支付方式</span>
				<span class="or_it2" id="pay_type">加载中</span>
			</p>
			<p class="or_item">
				<span class="or_it1">收件人</span>
				<span class="or_it2" id="receiver_name">加载中</span>
			</p>
			<p class="or_item">
				<span class="or_it1">联系电话</span>
				<span class="or_it2" id="receiver_phone">加载中</span>
			</p>
			<p class="or_item">
				<span class="or_it1">收货地址</span>
				<span class="or_it2" id="address">加载中</span>
			</p>
			<p class="or_item">
				<span class="or_it1">快递公司</span>
				<span class="or_it2" id="post_name">加载中</span>
			</p>
			<p class="or_item">
				<span class="or_it1">快递单号</span>
				<input type="text" class="post_no" id="foo" style="border:none;" />
				<span><a href="javascript:;" id="ywa1lrlink" data-clipboard-target="#foo" aria-label="复制成功！" class="or_it3">复制</a></span>
			</p>
			<div class="or_item">
				<span class="or_it1">退换押金金额</span>
				<div style="text-align: right;">
					<span class="or_it2" id="return_money">加载中</span>
					<p class="return_status_msg">加载中</p>
				</div>

			</div>
		</div>
		<button class="bulink" id="tuihuan">退换押金</button>
	</div>
	<div style="clear: both;"></div>

	<script src="js/jquery.min.js" type="text/javascript"></script>
	<script src="js/loading.js"></script>
	<script src="js/clipboard.min.js" type="text/javascript"></script>

</body>
<script type="text/javascript">
	$(function () {
		//订单详情信息
		var token1 = sessionStorage['token'];;
		var method = "Shop|shop_order_detail";
		var order_id = sessionStorage.getItem("order_id");
		$.ajax({
			type: 'POST',
			url: "http://www.rice.com/app/api/h5_access",
			contentType: "application/x-www-form-urlencoded; charset=utf-8",
			datatype: "JSON",
			data: {
				token: token1,
				method: method,
				order_id: order_id
			},
			success: function (data) {
				var data1 = JSON.parse(data);
				console.log(data1);
				$("#money").html(data1.data.money + "元");
				$('#status_name').html("点单状态：" + data1.data.status_name);
				$("#address").html(data1.data.address);
				$("#receiver_phone").html(data1.data.receiver_phone);
				$("#name").html(data1.data.name);
				$("#order_no").html(data1.data.order_no);
				$("#post_name").html(data1.data.post_name);
				$("#buy_num").html(data1.data.buy_num + "个");
				$("#pay_type").html(data1.data.pay_type);
				$("#receiver_name").html(data1.data.receiver_name);
				$("#foo").val(data1.data.post_no);
				$("#return_money").html(data1.data.return_money);
				$(".return_status_msg").html(data1.data.return_status_msg);


				if (data.is_return == "1") {
					//退换押金
					$('#tuihuan').click(function () {
						var token1 = sessionStorage['token'];;
						var method = "Shop|shop_order_return";
						var order_id = sessionStorage.getItem("order_id");

						$.ajax({
							type: 'POST',
							url: "http://www.rice.com/app/api/h5_access",
							contentType: "application/x-www-form-urlencoded; charset=utf-8",
							datatype: "JSON",
							data: {
								token: token1,
								method: method,
								order_id: order_id
							},
							success: function (data) {
								var data1 = JSON.parse(data);
								console.log(data1);
								alert(data1.message);
								location.reload();
							}
						})
					})
				} else {
					$('#tuihuan').attr("disabled", true)
				}
			}
		});




		//复制地址
		var clipboard = new Clipboard('#ywa1lrlink');
		clipboard.on('success', function (e) {
			var msg = e.trigger.getAttribute('aria-label');
			alert(msg);
			e.clearSelection();
		});
	})
</script>

</html>